# from selenium.webdriver.support.ui import Select # Select模块
# Select(下拉框定位).select_by_index() # 根据下标选择
# Select(下拉框定位).select_by_value() # 根据 选项的 value 属性值 选择
# Select(下拉框定位).select_by_visible_text() # 根据 选项的 文本信息选择


from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
import time

d = webdriver.Chrome()
d.get('http://192.168.0.125:9009/wp-login.php')
d.maximize_window()

username = d.find_element(By.CSS_SELECTOR, '[name="log"]')
username.send_keys('admin')

password = d.find_element(By.CSS_SELECTOR, '[name="pwd"]')
password.send_keys('admin123')
time.sleep(3)
login = d.find_element(By.CSS_SELECTOR, '[name="wp-submit"]')
login.click()
time.sleep(3)

set = d.find_element(By.CSS_SELECTOR, '[id="menu-settings"] [class="wp-menu-name"]')
set.click()
time.sleep(1)
js = 'window.scrollTo(0,1000);'
d.execute_script(js)
time.sleep(1)
op = d.find_element(By.CSS_SELECTOR, '[name="default_role"]')
Select(op).select_by_index(3)  # 根据下标选择
time.sleep(1)
Select(op).select_by_value('contributor')  # 根据 选项的 value 属性值 选择
time.sleep(1)
Select(op).select_by_visible_text('订阅者')  # 根据 选项的 文本信息选择
time.sleep(1)

d.quit()
